package com.study.service.impl.order;

import com.study.service.openfeign.MemberServiceFeign;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 订单服务中，调用本地的会员服务OpenFeign,
 * 再由openfeign实现负载均衡调到远程的会员服务。
 * @author: BacHe
 * @email: 1218585258@qq.com
 * @Date: 2020/9/8 23:54
 */
@RestController
public class OrderService {

    @Resource
    private MemberServiceFeign memberServiceFeign;

    @RequestMapping("/orderFeignToMember")
    public String orderFeignToMember(){
        String user = memberServiceFeign.getUser(1);
        return "orderFeignToMember-----:" + user;
    }

    @RequestMapping("/getServerPort")
    public String getServerPort(HttpServletRequest request) {
        String serverPort = request.getHeader("serverPort");
        String ip = request.getHeader("ip");
        return String.format("order service 响应：" +
                ",网关的端口号是：%s, 用户的ip:%s", serverPort, ip);
    }



}
